home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / morse / dspmorse / vid.c < prev    next >
C/C++ Source or Header  |  1993-11-28  |  4KB  |  243 lines

  1. //
  2. //    VID.C
  3. //        Video routines.
  4. //
  5.  
  6. #include "morse.h"
  7.  
  8. //
  9. //    Display a character in the "idle" display across the screen bottom.
  10. //
  11. void idlePutC(char c)
  12. {
  13.     // scroll the tone line (bottom) left
  14.     // add a character at the end of the line
  15.     asm {
  16.                                         // Save registers
  17.         push ax
  18.         push bx
  19.         push cx
  20.         push ds
  21.         push es
  22.         push di
  23.         push si
  24.                                         // source and destination segments
  25.         mov ax, VIDSEG
  26.         push ax
  27.         push ax
  28.         pop ds
  29.         pop es
  30.                                         // Dest & source offsets
  31.         mov di, 0x0E60
  32.         mov si, 0x0E62
  33.                                         // Set the move count (words)
  34.         mov cx, 0x004F
  35.                                         // Move the junk
  36.         rep movsw
  37.                                         // Restore registers
  38.         pop si
  39.         pop di
  40.         pop es
  41.         pop ds
  42.         pop cx
  43.         pop bx
  44.         pop ax
  45.     }
  46.     pokeb(VIDSEG, (160*24)-2, c);
  47. }
  48.  
  49. //
  50. //    Display a character in the "tone" display across the screen bottom.
  51. //
  52. void tonePutC(char c)
  53. {
  54.     // scroll the tone line (bottom) left
  55.     // add a character at the end of the line
  56.     asm {
  57.                                         // Save registers
  58.         push ax
  59.         push bx
  60.         push cx
  61.         push ds
  62.         push es
  63.         push di
  64.         push si
  65.                                         // source and destination segments
  66.         mov ax, VIDSEG
  67.         push ax
  68.         push ax
  69.         pop ds
  70.         pop es
  71.                                         // Dest & source offsets
  72.         mov di, 0x0F00
  73.         mov si, 0x0F02
  74.                                         // Set the move count (words)
  75.         mov cx, 0x004F
  76.                                         // Move the junk
  77.         rep movsw
  78.                                         // Restore registers
  79.         pop si
  80.         pop di
  81.         pop es
  82.         pop ds
  83.         pop cx
  84.         pop bx
  85.         pop ax
  86.     }
  87.     pokeb(VIDSEG, (160*25)-2, c);
  88. }
  89.  
  90. //
  91. //    Display a character in the "text" window.
  92. //
  93.  
  94. void textPutC(char c)
  95. {
  96.     static int x=BOXLEF+1;
  97.  
  98.     pokeb(VIDSEG,(x<<1)+((BOXDIV-1)*160), c);
  99.  
  100.     if ((++x)>=BOXRIG)
  101.     {
  102.             asm {
  103.                 push ax                    // save the registers we're using
  104.                 push bx
  105.                 push cx
  106.                 push dx
  107.                 push ds
  108.                 push es
  109.                 push di
  110.                 push si
  111.                                         // line to scroll into
  112.                 mov bx, BOXTOP+1
  113.                                         // source and destination segments
  114.                 mov ax, VIDSEG
  115.                 push ax
  116.                 push ax
  117.                 pop ds
  118.                 pop es
  119.             }
  120. lineloop:
  121.             asm {
  122.                                         // calculate dest line offset
  123.                 mov ax, 0x00A0
  124.                 mul bl
  125.                                         // calculate the left window inside
  126.                 mov dx, BOXLEF
  127.                 inc dx
  128.                 shl dx, 1
  129.                                         // combine them
  130.                 add ax, dx
  131.                 mov di, ax
  132.  
  133.                 cmp bx, BOXDIV-1        // see if we're done
  134.                 je scrolldone            // leave the scroll if so
  135.  
  136.                 add ax, 0xA0            // calculate offset of source
  137.                 mov si, ax
  138.  
  139.                 mov cx,(BOXRIG-BOXLEF)-1
  140.                 rep movsw                // move them
  141.  
  142.                 inc bx                    // go to the next line
  143.                 jmp lineloop            // loop around to calculate it
  144.             }
  145. scrolldone:
  146.             asm {
  147.                                         // AX = word to clear; CX = count
  148.                 mov ax, 0x0720
  149.                 mov cx, (BOXRIG-BOXLEF)-1
  150.                 rep stosw                // clear the last line in the window
  151.  
  152.                 pop si                    // restore the registers we've saved
  153.                 pop di
  154.                 pop es
  155.                 pop ds
  156.                 pop dx
  157.                 pop cx
  158.                 pop bx
  159.                 pop ax
  160.             }
  161.             x=BOXLEF+1;
  162.     }
  163. }
  164.  
  165. //
  166. //    Display a character in the "morse" window.
  167. //
  168.  
  169. void morsePutC(char c)
  170. {
  171.     static int x=BOXLEF+1;
  172.  
  173.     pokeb(VIDSEG,(x<<1)+((BOXBOT-1)*160), c);
  174.  
  175.     if ((++x)>=BOXRIG)
  176.     {
  177.             asm {
  178.                 push ax                    // save the registers we're using
  179.                 push bx
  180.                 push cx
  181.                 push dx
  182.                 push ds
  183.                 push es
  184.                 push di
  185.                 push si
  186.                                         // line to scroll into
  187.                 mov bx, BOXDIV+1
  188.                                         // source and destination segments
  189.                 mov ax, VIDSEG
  190.                 push ax
  191.                 push ax
  192.                 pop ds
  193.                 pop es
  194.             }
  195. lineloop:
  196.             asm {
  197.                                         // calculate dest line offset
  198.                 mov ax, 0x00A0
  199.                 mul bl
  200.                                         // calculate the left window inside
  201.                 mov dx, BOXLEF
  202.                 inc dx
  203.                 shl dx, 1
  204.                                         // combine them
  205.                 add ax, dx
  206.                 mov di, ax
  207.  
  208.                 cmp bx, BOXBOT-1        // see if we're done
  209.                 je scrolldone            // leave the scroll if so
  210.  
  211.                 add ax, 0xA0            // calculate offset of source
  212.                 mov si, ax
  213.                                         // word count to move
  214.                 mov cx, (BOXRIG-BOXLEF)-1
  215.                 rep movsw                // move them
  216.  
  217.                 inc bx                    // go to the next line
  218.                 jmp lineloop            // loop around to calculate it
  219.             }
  220. scrolldone:
  221.             asm {
  222.                                         // AX = clear word; CX = word count
  223.                 mov ax, 0x0720
  224.                 mov cx, (BOXRIG-BOXLEF)-1
  225.                 rep stosw
  226.  
  227.                 pop si                    // restore the registers we've saved
  228.                 pop di
  229.                 pop es
  230.                 pop ds
  231.                 pop dx
  232.                 pop cx
  233.                 pop bx
  234.                 pop ax
  235.             }
  236.             x=(BOXLEF+1);
  237.     }
  238. }
  239.  
  240. //
  241. //    end of VID.C
  242. //
  243.